/*
 * @Description: 全宗操作组件
 * @Author: Rfan
 * @Date: 2022-01-07 15:35:59
 * @LastEditTime: 2022-05-27 18:42:10
 */

import { useMemo, useState } from 'react';
import { Button, Space } from 'antd';
import cs from 'classnames';
import classNames from 'classnames/bind';
import { useArcTypeContext } from '../contexts/ArcTypeContext';
import AddDialog from './dialogs/AddDialog';
import CopyCreateDialog from './dialogs/CopyCreate';
import styles from '../styles/arcTypeMain.module.scss';

const cx = classNames.bind(styles);

const Operate = () => {
  const { selectFond } = useArcTypeContext();
  // 新增弹窗状态
  const [addDialogVisible, setAddDialogVisible] = useState(false);
  // 复制新增弹窗状态
  const [copyDialogVisible, setCopyDialogVisible] = useState(false);

  const showAddModal = () => {
    setAddDialogVisible(true);
  };

  const showCopyCreateModal = () => {
    setCopyDialogVisible(true);
  };

  return (
    <>
      <div className={cs('filter-container', cx('operate-wrap'))}>
        <p className="page-title">档案类型</p>
        <Space size="small">
          <Button type="primary" disabled={!selectFond.id} onClick={() => showAddModal()}>
            新建档案类型
          </Button>
          {/* <Button type="primary" disabled onClick={() => showCopyCreateModal()}> */}
          {/*  从...复制创建 */}
          {/* </Button> */}
        </Space>
      </div>
      {useMemo(
        () => (
          <AddDialog
            visible={addDialogVisible}
            onClose={() => {
              setAddDialogVisible(false);
            }}
          />
        ),
        [addDialogVisible]
      )}
      {useMemo(
        () => (
          <CopyCreateDialog
            visible={copyDialogVisible}
            onClose={() => {
              setCopyDialogVisible(false);
            }}
          />
        ),
        [copyDialogVisible]
      )}
    </>
  );
};

export default Operate;
